<template lang='pug'>
.InterContent(v-if="show")
  a.goods-header(:href="citem.linkUrl")
    img(:src="citem.picUrl | imgUrl", alt="")
  swiperRowBox(:clist="commodityArr",:small="true")
</template>
<script>
import { unique } from '@/config/utils'
import { getCommodityData } from '@/service/getData'
import swiperRowBox from './_swiper_row_box.vue'
export default {
  data() {
    return {
      show: true,
      commodityArr: [], // 商品列表
      commodityB2cIds: [], // 商品ID
    }
  },
  props: ['citem'],
  created() {
    this.getb2cIds()
    this.getCommodityList()
  },
  methods: {
    getb2cIds() {
      let sh = this.citem.elementDesc.split(',')
      let ids = this.citem.productSpecialFlag.split(',')
      let b2cids = [];
      ids.forEach(function(item, i) {
        let s = sh[i] || '0000000000';
        b2cids.push(`${s.replace(/(^\s+)|(\s+$)/g, "")}-${item.replace(/(^\s+)|(\s+$)/g, "")}`);
      });
      // sh.forEach(function (item, index) {
      //   b2cids.push(`${item.replace(/(^\s+)|(\s+$)/g, "")}-${ids[index].replace(/(^\s+)|(\s+$)/g, "")}`)
      // }, this);
      this.commodityB2cIds = b2cids
    },
    async getCommodityList() {
      let p = this.$store.state.position
      let commoditydata = await getCommodityData(p.cityCode, p.storeLocation, unique(this.commodityB2cIds))
      console.log(commoditydata)
      if (commoditydata.resultMsg == "成功") {
        this.commodityArr = commoditydata.resultData
      }
    },
    error(e) {
      e.target.src = "/static/images/pro-default.png"
    },
    to4Page(item) {
      this.$router.push({ path: `/detail/${item.cmmdtyCode}/${item.supplierCode}` })
    }
  },
  components: {
    swiperRowBox
  }
}
</script>
<style lang='scss' scoped>
@import './tool.scss';
.InterContent {
  width: toRem(719);
  margin: 0 auto;
  .goods-header {
    display: block;
    width: 100%;
    img {
      width: 100%;
      height: toRem(274);
    }
  }
}
</style>
